import serial
import time
#设置串口、波特率以及发送数据间隔
ser = serial.Serial("/dev/ttyUSB0",9600,timeout=0.01) 
data = ""

rhbase = [20,20,21,21,22,22,23,23,24,24,
          25,25,26,26,27,27,28,28,29,29,
          30,30,31,31,32,32,33,33,34,34,
          35,35,36]
rhdata = [1030,1027,1025,1023,1020,1017,1015,1013,1010,1007,
         1005,1003,1000,997,995,993,990,987,985,983,
         980,977,975,973,970,967,965,963,960,957,
         955,953,950]
result = 0
while 1:
    while ser.inWaiting() > 0:
        data = ser.readline()
    if data != "":
        if len(data)==8:
        # if data[0]==170 and data[1]==85:
            for i in range(len(rhdata)-1):
                rh = int(data[3])*1000+int(data[4])*100+int(data[5])*10+int(data[6])
                if rhdata[i] >= rh and rh > rhdata[i+1]:
                    result = rhbase[i]
                    break
            print(int(data[1]),int(data[2]),result)
